package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    //@Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    @AutoFill(value = OperationType.INSERT)
    int insert(Dish dish);

    Long getDishId(String name);

    Page<DishVO> dishPageQuery(Dish dish);

    void delete(Long dishId);
    @AutoFill(value = OperationType.UPDATE)
    int update(Dish dish);

    Dish getDish(Long id);

    List<Dish> getDishList(Dish dish);

    /**
     * 统计套餐内菜品为停售的数量
     * @param dishId
     * @return
     */
    int getDishStatus(@Param("dishId") Long dishId);
    /**
     * 根据条件统计菜品数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);

}
